Skip to content

fix(ai): classify DeepSeek prompt cache lifetime - #1237

Open
Altairpaca wants to merge 1 commit into
code-yeongyu:mainfrom
Altairpaca:fix/831-deepseek-cache-lifetime-rebuild-v2
Open

fix(ai): classify DeepSeek prompt cache lifetime#1237
Altairpaca wants to merge 1 commit into
code-yeongyu:mainfrom
Altairpaca:fix/831-deepseek-cache-lifetime-rebuild-v2

Conversation

@Altairpaca

@Altairpaca Altairpaca commented Aug 31, 2026

Copy link
Copy Markdown

Summary

Rebuilds the DeepSeek prompt-cache lifetime fix on current main (44923014d) and supersedes stale draft PR #835.

Direct DeepSeek API sessions use provider-managed automatic caching. They must not be treated as having a deterministic five-minute TTL, fabricated cache-savings claims, or cache-preservation events intended for fixed-TTL providers.

Changes

  • Add typed PromptCacheLifetime classification at the pi-ai provider boundary: fixed, automatic, disabled, or unknown.
  • Detect DeepSeek by provider id or parsed canonical api.deepseek.com hostname, including case-insensitive host matching while rejecting malformed and spoofed URLs.
  • Give explicit cacheRetention: "none" precedence over automatic detection.
  • Use a 3570-second liveness backstop for automatic caching without presenting it as a cache TTL.
  • Suppress cache metrics and cache-warm entries for disabled caching; preserve fixed and unknown behavior, including unknown zero-token absence.
  • Cover scheduling, metrics, renderer copy, resolver edge cases, and the unknown zero-token regression in test/suite/regressions/issue-831-unknown-cache-metrics.test.ts.

Verification

  • AI focused suites: 2 files, 38 tests passed.
  • Coding-agent focused suites: 5 files, 49 tests passed, including the issue regression.
  • git diff --check: passed.
  • LSP diagnostics: no errors in all changed TypeScript files.

The full root check and real-CLI QA are currently environment-blocked in the isolated worktree: the worktree dependency tree lacks the declared @bufbuild/protobuf and tsx packages, and this host is Node v22.23.1 while the repository root requires Node 24. The focused tests were run with disposable links to the already-installed locked protobuf package; those links were removed after each run. No credentials or network provider calls were used.

This branch is based directly on current main and intentionally contains only the 13 files in the verified rebuild.


Summary by cubic

Treats DeepSeek's automatic prompt caching as provider-managed with no fixed TTL instead of assuming the usual five-minute value. Explicitly disabled caching now suppresses all cache-warm telemetry, and issue #831's unknown-lane zero-token metric regression is fixed.

  • Adds typed PromptCacheLifetime classification (fixed, automatic, disabled, unknown) at the @earendil-works/pi-ai provider boundary and exports it.
  • Detects DeepSeek by provider id or the canonical api.deepseek.com hostname, case-insensitively, and rejects malformed or lookalike URLs.
  • Explicit cacheRetention: "none" now overrides provider detection.
  • Automatic caching schedules a 3570-second liveness wake without reporting a TTL or savings estimate.
  • Disabled caching keeps the goal alive via the 240-second fallback but drops all cache-warm events, metrics, and transcript copy.
  • Restores issue bug(prompt-cache): direct DeepSeek is treated as a fixed 5m TTL, forcing unnecessary 4m30 Goal cache-warm wakes #831 behavior where unknown lanes with zero cached tokens emit no metrics.

Written for commit 30c673e. Summary will update on new commits.

Review in cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant